package com.airconditioning.util;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * Description:
 * Created: wangkaicun @ 2017-10-20 下午10:47
 */
@EqualsAndHashCode(callSuper = false)
@Data
// @JsonInclude(JsonInclude.Include.NON_NULL) //如果为空的属性，去除
public class BaseDto {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer isPage;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer pageIndex;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer pageSize;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String orderBy;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<Long> ids;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long count;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Boolean openSp;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer year;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer mouth;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date timeFrom;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date timeTo;

    public void init(){
        if (this.pageIndex == null || this.pageIndex <0) {
            this.pageIndex = 1;
        }
        if (this.pageSize==null||this.pageSize<1) {
            this.pageSize = 10;
        }
    }
}
